{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "third-extent",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "early-airfare",
   "metadata": {},
   "outputs": [],
   "source": [
    "custFile = '客户点需求信息.txt'\n",
    "distFile = '距离矩阵.txt'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "protected-forth",
   "metadata": {},
   "outputs": [],
   "source": [
    "custInfo = []\n",
    "with open(custFile) as fl:\n",
    "    for line in fl.readlines():\n",
    "        custInfo.append(line.split())\n",
    "distInfo = []\n",
    "with open(distFile) as fl:\n",
    "    for line in fl.readlines():\n",
    "        distInfo.append(line.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "threaded-techno",
   "metadata": {},
   "outputs": [],
   "source": [
    "custInfo = np.array(custInfo).astype('int')\n",
    "distInfo = np.array(distInfo).astype('float')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "checked-finger",
   "metadata": {},
   "outputs": [],
   "source": [
    "lens = [10,20,50,100,200,500,1000,2021]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "macro-enemy",
   "metadata": {},
   "outputs": [],
   "source": [
    "for num in lens:\n",
    "    tempCustInfo = custInfo[:num]\n",
    "    tempDistInfo = distInfo[:num+2]\n",
    "    tempDistInfo = tempDistInfo[:,:num+2]\n",
    "    np.savetxt(\"客户需求信息\"+str(num)+\".txt\", tempCustInfo,fmt='%d')\n",
    "    np.savetxt(\"距离矩阵\"+str(num)+\".txt\", tempDistInfo,fmt='%.3f')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "virgin-chase",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.savetxt?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "meaning-bracket",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
